# @Version        : 1.0
# @Update Time    : 2024/11/14 20:30
# @File           : dict_schema.py
# @IDE            : PyCharm
# @Desc           : 字典模型
from fastapi_utils.api_model import APIModel
from pydantic import Field
from typing import Optional
from fastapi import Depends
from src.core.dependencies import QueryParams, Paging


class DictTypeParams(QueryParams):
    def __init__(
        self,
        params: Paging = Depends(Paging),
    ):
        super().__init__(params)


class DictTypeSchema(APIModel):
    """
    字典类型表
    """

    dict_name: Optional[str] = Field(default="", description="字典名称")
    dict_type: str = Field(default=..., description="字典类型")
    status: Optional[str] = Field(default="1", description="状态（1正常 2停用）")
    remark: Optional[str] = Field(default="", description="备注")


class DictTypeSchemaOut(DictTypeSchema):
    id: int = Field(..., description="字典主键")


class DictDataSchema(APIModel):
    """
    字典数据表
    """

    dict_sort: Optional[int] = Field(default=0, description="字典排序")
    dict_label: Optional[str] = Field(default="", description="字典标签")
    dict_value: Optional[str] = Field(default="", description="字典键值")
    dict_type_id: int = Field(description="字典类型ID")
    is_default: Optional[str] = Field(default="N", description="是否默认（Y是 N否）")
    status: Optional[str] = Field(default="1", description="状态（1正常 2停用）")
    remark: Optional[str] = Field(default="", description="备注")


class DictDataSchemaOut(DictDataSchema):
    id: int = Field(..., description="字典数据主键")


class DictTypeSchemaCache(DictTypeSchema):
    id: int = Field(..., description="字典主键")
    dict_datas: list[DictDataSchema] = Field(default=[], description="字典数据")


class DictOptions(APIModel):
    """
    字典查询参数
    """

    label: Optional[str] = Field(default="", description="字典标签")
    value: Optional[str] = Field(default="", description="字典键值")
